<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>OrangeCNC - ARISC firmware documentation: mod_timer.c</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">OrangeCNC - ARISC firmware documentation
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('mod_timer_8c-example.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">mod_timer.c</div>  </div>
</div><!--header-->
<div class="contents">
<p><b>Usage example 1</b>: get code execution time in CPU ticks</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;stdint.h&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="mod__timer_8h.html">mod_timer.h</a>&quot;</span></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> <a name="a0"></a><a class="code" href="main_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">    uint32_t i, n, ticks;</div><div class="line"></div><div class="line">    <a name="a1"></a><a class="code" href="mod__timer_8c.html#a161432848a326da3a1ea7765fc2bc023">timer_start</a>(); <span class="comment">// start timer</span></div><div class="line">    <a name="a2"></a><a class="code" href="mod__timer_8c.html#aef86d8f8e96209074113a6579ba042ce">timer_cnt_set</a>(0); <span class="comment">// reset timer counter</span></div><div class="line"></div><div class="line">    <span class="comment">// your code</span></div><div class="line">    <span class="keywordflow">for</span> ( i = 0, n = 0; i &lt; 123456; i++ ) n = i*i;</div><div class="line"></div><div class="line">    ticks = <a name="a3"></a><a class="code" href="mod__timer_8c.html#ac0b22a5df951fddf6977edf3b1cd55f6">timer_cnt_get</a>(); <span class="comment">// get execution time of your code (in CPU ticks)</span></div><div class="line">    <a name="a4"></a><a class="code" href="mod__timer_8c.html#aa04078f48a0e8f5b6860a393ad06b535">timer_stop</a>(); <span class="comment">// stop timer</span></div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --><p><b>Usage example 2</b>: using fast macros to get code execution time in CPU ticks</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;or1k-sprs.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;or1k-support.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;stdint.h&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="mod__timer_8h.html">mod_timer.h</a>&quot;</span></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> <a class="code" href="main_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">    uint32_t i, n, ticks;</div><div class="line"></div><div class="line">    <a name="a5"></a><a class="code" href="mod__timer_8h.html#a61d5531e2b8556916fa42733208f0659">TIMER_START</a>(); <span class="comment">// start timer</span></div><div class="line">    <a name="a6"></a><a class="code" href="mod__timer_8h.html#a6cb2b7772151124948e5d17d1c6e08ea">TIMER_CNT_SET</a>(0); <span class="comment">// reset timer counter</span></div><div class="line"></div><div class="line">    <span class="comment">// your code</span></div><div class="line">    <span class="keywordflow">for</span> ( i = 0, n = 0; i &lt; 123456; i++ ) n = i*i;</div><div class="line"></div><div class="line">    ticks = <a class="code" href="mod__timer_8h.html#a6cb2b7772151124948e5d17d1c6e08ea">TIMER_CNT_SET</a>(); <span class="comment">// get execution time of your code (in CPU ticks)</span></div><div class="line">    <a name="a7"></a><a class="code" href="mod__timer_8h.html#a8055a02ef3688352212e0dba357905b3">TIMER_STOP</a>(); <span class="comment">// stop timer</span></div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --><div class="fragment"></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
